package hoangbn.apps.adapter;

import hoangbn.apps.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class PlaceAdapter extends ArrayAdapter<String> {

	private Context context;
	private String[] objects;

	public PlaceAdapter(Context context, int resource, String[] objects) {
		super(context, resource, objects);
		this.context = context;
		this.objects = objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View rowView = null;
		LayoutInflater inflater = (LayoutInflater) this.context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		if (convertView == null) {
			rowView = inflater.inflate(R.layout.activity_place, parent, false);
		} else {
			rowView = convertView;
		}

		TextView tvPlaceItem = (TextView) rowView
				.findViewById(R.id.tvPlaceItem);
		tvPlaceItem.setText(objects[position]);
		return rowView;
	}
}
